//
//  YXYGroupHomePageTableViewCell.m
//  Topit
//
//  Created by dllo on 15/12/10.
//  Copyright © 2015年 YXY. All rights reserved.
//

#import "YXYGroupHomePageTableViewCell.h"

@implementation YXYGroupHomePageTableViewCell
- (void)dealloc {
    [_name release];
    [_myImage release];
    [_pnum release];
    [_mnum release];
    [_ts release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.myImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self addSubview:_myImage];
        [_myImage release];
        
        self.name = [[UILabel alloc] initWithFrame:CGRectZero];
        _name.font = [UIFont systemFontOfSize:12];
        [self addSubview:_name];
        [_name release];
        
        self.pnum = [[UILabel alloc] initWithFrame:CGRectZero];
        _pnum.font = [UIFont systemFontOfSize:8];
        _pnum.textColor = [UIColor grayColor];
        [self addSubview:_pnum];
        [_pnum release];
        
        self.mnum = [[UILabel alloc] initWithFrame:CGRectZero];
        _mnum.font = [UIFont systemFontOfSize:8];
        _mnum.textColor = [UIColor grayColor];
        [self addSubview:_mnum];
        [_mnum release];
        
        self.ts = [[UILabel alloc] initWithFrame:CGRectZero];
        _ts.font = [UIFont systemFontOfSize:8];
        _ts.textColor = [UIColor grayColor];
        [self addSubview:_ts];
        [_ts release];
        
    }
    return self;
}

- (void)setGroupHomePageModel:(YXYGroupHomePageModel *)groupHomePageModel {
    if (_groupHomePageModel != groupHomePageModel) {
        [_groupHomePageModel release];
        _groupHomePageModel = [groupHomePageModel retain];
    }
    _name.text = _groupHomePageModel.name;
    [_name nightMode];
    
    [_myImage sd_setImageWithURL:[NSURL URLWithString:_groupHomePageModel.icon[@"url"]]];
    [_myImage nightMode];
    
    _mnum.text = [NSString stringWithFormat:@"%@ %@", _groupHomePageModel.mnum, @"话题"];
    [_mnum nightMode];
    
    _pnum.text = [NSString stringWithFormat:@"%@ %@", _groupHomePageModel.pnum, @"成员"];
    [_pnum nightMode];
    
    _ts.text = _groupHomePageModel.last_ts;
    [_ts nightMode];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    _myImage.frame = CGRectMake(5, 5, self.height - 10, self.height - 10);
    
    _name.frame = CGRectMake(_myImage.origin.x + _myImage.width + 5, 10, self.width - _myImage.width, 10);
    
    _mnum.frame = CGRectMake(_name.origin.x + 5, _name.origin.y + 15, 70, 10);
    
    _pnum.frame = CGRectMake(_mnum.origin.x + 80, _mnum.origin.y, 70, 10);
    
    _ts.frame = CGRectMake(self.width - 85, _pnum.origin.y, 70, 10);
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
